package com.genesis.yunnanji.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.CommentBean;
import com.genesis.yunnanji.utils.DateUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/11/29.
 */

public class CommentAdapter extends BaseQuickAdapter<CommentBean.ResultBean.ListBean, BaseViewHolder> {
    private int cate;

    public CommentAdapter(int cate, @Nullable List<CommentBean.ResultBean.ListBean> data) {
        super(R.layout.layout_comment_item, data);
        this.cate = cate;
    }

    @Override
    protected void convert(BaseViewHolder helper, CommentBean.ResultBean.ListBean item) {

        if (cate == 1) {
            if (!TextUtils.isEmpty(item.getNickname())) {
                helper.setText(R.id.tv_commentitem_text, "你在《" + item.getSource_title() + "》回复了" + item.getNickname() + "的评论");

            } else {
                helper.setText(R.id.tv_commentitem_text, "你在《" + item.getSource_title() + "》发表了评论");
            }
            helper.setText(R.id.tv_commentitem_content, item.getContent());
            helper.setText(R.id.tv_commentitem_time, DateUtils.getTimeOfYMDHMS(item.getAdd_time()));
        } else {

            helper.setText(R.id.tv_commentitem_text, item.getNickname() + "在《" + item.getSource_title() + "》回复了你的评论");
            helper.setText(R.id.tv_commentitem_content, item.getContent());
            helper.setText(R.id.tv_commentitem_time, DateUtils.getTimeOfYMDHMS(item.getAdd_time()));
        }
        helper.addOnClickListener(R.id.tv_commentitem_check);

    }
}
